package edu.info.manager.dao;


import edu.info.manager.domain.TeacherJavaBean;

public class TeacherDao {
    private static TeacherJavaBean Tea[] = new TeacherJavaBean[5];

    public static TeacherJavaBean[] FindId() {
        return Tea;
    }



    public boolean Addteacher(TeacherJavaBean tea) {
        int index = -1;
        for (int i = 0; i < Tea.length; i++) {
            TeacherJavaBean teacherJavaBean = Tea[i];
            if (Tea[i] == null) {
                index = i;
                break;
            }
        }
        if (index == -1) {
            return false;
        } else {
            return true;
        }
    }


    public int GetIndex(String id) {
        int index = -1;
        for (int i = 0; i < Tea.length; i++) {
            TeacherJavaBean value = Tea[i];
            if (value != null && value.getId().equals(id)) {
                index = i;
                break;
            }
        }
        return index;
    }

    public boolean UpdateTeacher(String updateid, TeacherJavaBean newstu) {
        int index = GetIndex(updateid);
        Tea[index] = newstu;
        return true;
    }

    public boolean DeleteTeacher(String delnum) {
        int index = GetIndex(delnum);
        Tea[index]=null;
        return true;
    }
}